﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Forwarding</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="~/Areas/Forwarding/Contents/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Areas/Forwarding/Contents/css/font-awesome.min.css" rel="stylesheet" />
    <link href="~/Areas/Forwarding/Contents/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <style>
        #tbAccountsReceivableDetailFreight th {
         width:5.88%;
         text-align:center;
        }
    </style>
</head>
<body class="gray-bg" style="font-family:华文行楷">
    <!-- 页面 -->
    <div class="wrapper wrapper-content animated fadeInRight">
        <!-- 应收运费明细报表 -->
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    @*list*@
                    <div class="ibox-title">
                        <h5>应收运费明细报表</h5>
                        <div class="ibox-tools">
                            <a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
                                <i class="glyphicon glyphicon-list-alt"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li>
                                    <a onclick="Print()">打印</a>
                                </li>
                                <li>
                                    <a onclick="EtrustDerive()">导出</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    @*Select*@
                    <div class="ibox-content">
                        <form class="form-horizontal" role="form" id="Search" action="" method="post">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <div class="col-sm-3">
                                        <label class="col-sm-3 control-label">到厂时间:</label>
                                        <div class="col-sm-9">
                                            <input class="layui-input" id="test1-1" placeholder="yyyy-MM-dd HH:mm:ss" type="text" name="ArriveTime" onclick="Laydate()" oninput="Search()">
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <label class="col-sm-3 control-label">至:</label>
                                        <div class="col-sm-9">
                                            <input class="layui-input" id="test1-2" placeholder="yyyy-MM-dd HH:mm:ss" type="text" name="ArriveTimes" onclick="Laydate()" oninput="Search()" onchange="Search()">
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <label class="col-sm-3 control-label">客户简称:</label>
                                        <div class="col-sm-9">
                                            <select type="text" class="layui-input" id="ClientAbbreviationa" onchange="Search()" name="ClientAbbreviation"></select>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <label class="col-sm-3 control-label">签约公司:</label>
                                        <div class="col-sm-9">
                                            <select type="text" class="layui-input" id="ClientTypesID" onchange="Search()" name="ClientTypesID"></select>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-3">
                                        <label class="col-sm-3 control-label">做柜数量:</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="layui-input" readonly  id="ZGS">
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <label class="col-sm-3 control-label">应收合计:</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="layui-input" readonly value="0" id="SHJ">
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <label class="col-sm-3 control-label">应付合计:</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="layui-input" readonly value="0">
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <label class="col-sm-3 control-label">合计:</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="layui-input" readonly value="0" id="HJ">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    @*table*@
                    <div class="ibox-content">
                        <table class="table table-striped table-bordered table-hover dataTables-example" id="tbAccountsReceivableDetailFreight">
                            <thead>
                                <tr>
                                    <th w_check="true">序号</th>
                                    <th w_index="SettleAccounts">费用类型</th>
                                    <th w_index="ExpenseName">费用名称</th>
                                    <th w_index="WorkCategory">作业类别</th>
                                    <th w_index="UnitPrice">金额</th>
                                    <th w_index="EtrustType">状态</th>
                                    <th w_index="ClientAbbreviation">客户简称</th>
                                    <th w_index="ClientAbbreviation">工厂名称</th>
                                    <th w_index="ClientSite">工厂地址</th>
                                    <th w_index="ContactsName">工厂联系人</th>
                                    <th w_index="ContactsPhone">工厂联系电话</th>
                                    <th w_index="arriveTimes">到厂时间</th>
                                    <th w_index="CabinetType">箱型</th>
                                    <th w_index="CarriageNumber">运输单号</th>
                                    <th w_index="BookingSpace">订舱号S/0</th>
                                    <th w_index="Seal">封条号</th>
                                    <th w_index="HangCi">航次</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Bootstrap -->
    <script src="~/Content/bootstrap-3.3.7-dist/js/jquery-2.0.3.min.js"></script>
    <script src="~/Content/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <!-- Bsgrid -->
    <script src="~/Content/jquery.bsgrid-1.37/builds/merged/bsgrid.all.min.js"></script>
    <script src="~/Content/jquery.bsgrid-1.37/builds/js/lang/grid.zh-CN.min.js"></script>
    <!-- 提交表单 -->
    <script src="~/Content/js/jquery.form.js"></script>
    <!-- 弹出框 -->
    <script src="~/Content/layer/layer.js"></script>
    <!-- layui -->
    <script src="~/Content/layui/layui.js"></script>
    <!-- 下拉框,点击行js -->
    <script src="~/Content/js/combobox.js"></script>
    <!-- 自动回填 -->
    <script src="~/Content/js/customfunction.js"></script>
    <script>
        var A = 0;
        //查询
        function Laydate() {
            $(".laydate-btns-clear").attr("onclick", 'Search()')
            $(".laydate-btns-now").attr("onclick", 'Search()')
            $(".laydate-btns-confirm").attr("onclick", 'Search()')
        }
        //layerdate
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#test1-1'
              , type: 'datetime'
            });
            laydate.render({
                elem: '#test1-2'
              , type: 'datetime'
            });
        });
        //页面加载
        $(function () {
            //表格绑定
            tbAccountsReceivableDetailFreight = $.fn.bsgrid.init('tbAccountsReceivableDetailFreight', {
                url: "/Forwarding/Statement/SelectAccountsReceivableDetailFreight?AccountsReceivableDetailFreight=" + true,
                pageSize: 10,
                autoLoad: true,
                pageSizeSelect: false,
                displayBlankRows: false,
                pagingLittleToolbar: false,
                pagingToolbarAlign: "right",
                event: {
                    customRowEvents: {
                        click: function (record, rowIndex, trObj, options) {
                            Check("#tbAccountsReceivableDetailFreight  tr", rowIndex + 1);
                            A = 0;
                            for (var i = 0; i < $("#tbAccountsReceivableDetailFreight tbody tr").length; i++) {
                                if ($("#tbAccountsReceivableDetailFreight tbody tr").eq(i).children().eq(0).children().prop('checked') == true) {
                                    if ($("#tbAccountsReceivableDetailFreight tbody tr").eq(i).children().eq(4).html() == "" ||
                                        $("#tbAccountsReceivableDetailFreight tbody tr").eq(i).children().eq(4).html() == null ||
                                        $("#tbAccountsReceivableDetailFreight tbody tr").eq(i).children().eq(4).html() == undefined) {
                                        $("#tbAccountsReceivableDetailFreight tbody tr").eq(i).children().eq(4).html()=0
                                    }
                                    A = (parseFloat(A) + parseFloat($("#tbAccountsReceivableDetailFreight tbody tr").eq(i).children().eq(4).html())).toFixed(2)
                                }
                            }
                            $("#SHJ").val(A);
                            $("#HJ").val(A);
                        }
                    }
                }
            })
            //下拉框绑定
            appendOptions("ClientAbbreviationa", "/Forwarding/Forwarding/Client?ClientAbbreviation=" + 1, "ClientAbbreviation")
            appendOptions("TiGuiDiDiana", "/Forwarding/Forwarding/Mention", "TiGuiDiDian")
            appendOptions("HuaiGuiDiDiana", "/Forwarding/Forwarding/Mention", "HuaiGuiDiDian")
            appendOptions("TiGuiDiDianID", "/Forwarding/Forwarding/Mention", "TiGuiDiDian")
            appendOptions("HuaiGuiDiDianID", "/Forwarding/Forwarding/Mention", "HuaiGuiDiDian")
            appendOptions("ClientCode", "/Forwarding/Forwarding/Client?ClientID=" + 1, "ClientCode")
            appendOptions("MessageID", "/Main/Message", "Message")
            appendOptions("Message", "/Main/Message", "Message")
            appendOptions("ShipID", "/Forwarding/Forwarding/Ship", "Ship")
            appendOptions("PortID", "/Forwarding/Forwarding/Port", "Port")
            appendOptions("GoalHarborID", "/Forwarding/Forwarding/Port", "GoalHarbor")
            appendOptions("UndertakeID", "/Forwarding/Forwarding/SelectUndertake", "Undertake")
            appendOptions("UndertakeIDs", "/Forwarding/Forwarding/SelectUndertake", "Undertake")
            appendOptions("UndertakeIDl", "/Forwarding/Forwarding/SelectUndertake", "Undertake")
            appendOptions("ClientTypesID", "/Forwarding/Forwarding/SelectUndertake", "MichielMol")
            //做柜数量
            $.post("/Forwarding/Statement/SelectZuoGui", function (data) {
                $("#ZGS").val(data);
            })
        });
        //查询
        function Search() {
            if ($("#Search [name='ArriveTime']").val() == undefined || $("#Search [name='ArriveTime']").val() == null) {
                $("#Search [name='ArriveTime']").val() = "";
            }
            if ($("#Search [name='ArriveTimes']").val() == undefined || $("#Search [name='ArriveTimes']").val() == null) {
                $("#Search [name='ArriveTimes']").val() = "";
            }
            tbAccountsReceivableDetailFreight.search({
                EtrustNmber: $("#Search [name='EtrustNmber']").val(),
                Cupboard: $("#Search [name='Cupboard']").val(),
                Seal: $("#Search [name='Seal']").val(),
                ArriveTime: $("#Search [name='ArriveTime']").val(),
                ArriveTimes: $("#Search [name='ArriveTimes']").val(),
                ClientAbbreviation: $("#Search [name='ClientAbbreviation']").val(),
                TiGuiDiDianID: $("#Search [name='TiGuiDiDianID']").val(),
                HuaiGuiDiDianID: $("#Search [name='HuaiGuiDiDianID']").val(),
                ClientTypeID: $("#Search [name='ClientTypeID']").val(),
                ClientTypesID: $("#Search [name='ClientTypesID']").val(),
                VehicleInformationID: $("#Search [name='VehicleInformationID']").val(),
                ChauffeurID: $("#Search [name='ChauffeurID']").val()
            });
            A = 0;
            $("#SHJ").val(A);
            $("#HJ").val(A);
        }
        //导出
        function EtrustDerive() {
            layer.confirm("确认要导出应收运费明细报表吗？", {
                icon: 3,
                btn: ['确定', '取消']
            }, function (layerIndex) {
                layer.close(layerIndex);
                window.open("/Forwarding/Statement/SelectAccountsReceivableDetailFreight?EtrustNmber=" + $("#Search [name='EtrustNmber']").val() +
                                                                    "&Cupboard=" + $("#Search [name='Cupboard']").val() +
                                                                    "&Seal=" + $("#Search [name='Seal']").val() +
                                                                    "&ArriveTime=" + $("#Search [name='ArriveTime']").val() +
                                                                    "&ArriveTimes=" + $("#Search [name='ArriveTimes']").val() +
                                                                    "&ClientAbbreviation=" + $("#Search [name='ClientAbbreviation']").val() +
                                                                    "&TiGuiDiDianID=" + $("#Search [name='TiGuiDiDianID']").val() +
                                                                    "&HuaiGuiDiDianID=" + $("#Search [name='HuaiGuiDiDianID']").val() +
                                                                     "&ClientTypeID=" + $("#Search [name='ClientTypeID']").val() +
                                                                    "&ClientTypesID=" + $("#Search [name='ClientTypesID']").val() +
                                                                    "&VehicleInformationID=" + $("#Search [name='VehicleInformationID']").val() +
                                                                    "&ChauffeurID=" + $("#Search [name='ChauffeurID']").val() +
                                                                    "&AccountsReceivableDetailFreight=" + true +
                                                                    "&V=" + true)
            })
        }
        //打印
        function Print() {
            layer.confirm("确认要打印应收运费明细报表吗？", {
                icon: 3,
                btn: ['确定', '取消']
            }, function (layerIndex) {
                layer.close(layerIndex);
                window.open("/Forwarding/Statement/SelectAccountsReceivableDetailFreight?EtrustNmber=" + $("#Search [name='EtrustNmber']").val() +
                                                               "&Cupboard=" + $("#Search [name='Cupboard']").val() +
                                                               "&Seal=" + $("#Search [name='Seal']").val() +
                                                               "&ArriveTime=" + $("#Search [name='ArriveTime']").val() +
                                                               "&ArriveTimes=" + $("#Search [name='ArriveTimes']").val() +
                                                               "&ClientAbbreviation=" + $("#Search [name='ClientAbbreviation']").val() +
                                                               "&TiGuiDiDianID=" + $("#Search [name='TiGuiDiDianID']").val() +
                                                               "&HuaiGuiDiDianID=" + $("#Search [name='HuaiGuiDiDianID']").val() +
                                                                "&ClientTypeID=" + $("#Search [name='ClientTypeID']").val() +
                                                               "&ClientTypesID=" + $("#Search [name='ClientTypesID']").val() +
                                                               "&VehicleInformationID=" + $("#Search [name='VehicleInformationID']").val() +
                                                               "&ChauffeurID=" + $("#Search [name='ChauffeurID']").val() +
                                                               "&AccountsReceivableDetailFreight=" + true +
                                                               "&V1=" + true)
            })
        }
    </script>
</body>
</html>
